package net.begincode.blog.controller;

import net.begincode.biz.BlogBiz;
import net.begincode.blog.bean.vo.BlogBaseInfo;
import net.begincode.common.ApiResponse;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
 * 推荐
 */
@Controller
@RequestMapping("blog/recommend")
public class RecommendController {

    @Resource
    private BlogBiz blogBiz;

    @RequestMapping(value = "", method = RequestMethod.POST)
    @ResponseBody
    public ApiResponse<BlogBaseInfo> queryRecommend(@RequestParam(value="typeId",required=false) Long typeId){
       List<BlogBaseInfo> recommendInfoList =  blogBiz.queryRecommend(typeId,1);
       if(CollectionUtils.isEmpty(recommendInfoList)){
           return ApiResponse.fail("没有推荐信息");
       }
       return ApiResponse.success(recommendInfoList.get(0));
    }


}
